package com.javashizhan.demo.restclient.client;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import com.javashizhan.demo.restclient.domain.ResponseResult;
import com.javashizhan.demo.restclient.domain.User;

/**
 * 
 * @Description: 模拟客户端controller，方便通过swagger来测试
 *
 * @author 飞流
 * @date 2019年8月16日
 * @知识星球 Java实战营
 * @微信公众号 JAVA栈实战营
 * @站点 http://javashizhan.com/
 *
 */
@RestController
public class CallUserController {

	@Autowired
	private UserClient client;

	@PostMapping("/callFindUserByName")
	public ResponseResult<User> callFindUserByName(@RequestBody String userName) throws Exception {
		ResponseResult<User> response = client.findUserByName(userName);
		return response;
	}

	@PostMapping("/callCreateUser")
	public ResponseResult<Void> callCreateUser(@RequestBody User user) throws Exception {
		return client.createUser(user);
	}
}
